/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.admanager.generalpattern.plugin.generalpattern.impl;

import java.util.Collection;

import org.admanager.generalpattern.plugin.generalpattern.Element;
import org.admanager.generalpattern.plugin.generalpattern.MergingOperator;
import org.admanager.generalpattern.plugin.generalpattern.Multiplicity;
import org.admanager.generalpattern.plugin.generalpattern.Pattern;
import org.admanager.generalpattern.plugin.generalpattern.Role;
import org.admanager.generalpattern.plugin.generalpattern.generalpatternPackage;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Pattern</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.admanager.generalpattern.plugin.generalpattern.impl.PatternImpl#getOperators <em>Operators</em>}</li>
 *   <li>{@link org.admanager.generalpattern.plugin.generalpattern.impl.PatternImpl#getElements <em>Elements</em>}</li>
 *   <li>{@link org.admanager.generalpattern.plugin.generalpattern.impl.PatternImpl#getMultiplicities <em>Multiplicities</em>}</li>
 *   <li>{@link org.admanager.generalpattern.plugin.generalpattern.impl.PatternImpl#getContainingRoles <em>Containing Roles</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class PatternImpl extends ElementImpl implements Pattern {
	/**
	 * The cached value of the '{@link #getOperators() <em>Operators</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOperators()
	 * @generated
	 * @ordered
	 */
	protected EList operators;

	/**
	 * The cached value of the '{@link #getElements() <em>Elements</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getElements()
	 * @generated
	 * @ordered
	 */
	protected EList elements;

	/**
	 * The cached value of the '{@link #getMultiplicities() <em>Multiplicities</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getMultiplicities()
	 * @generated
	 * @ordered
	 */
	protected EList multiplicities;

	/**
	 * The cached value of the '{@link #getContainingRoles() <em>Containing Roles</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getContainingRoles()
	 * @generated
	 * @ordered
	 */
	protected EList containingRoles;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PatternImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return generalpatternPackage.Literals.PATTERN;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getOperators() {
		if (operators == null) {
			operators = new EObjectContainmentEList(MergingOperator.class, this, generalpatternPackage.PATTERN__OPERATORS);
		}
		return operators;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getElements() {
		if (elements == null) {
			elements = new EObjectContainmentEList(Element.class, this, generalpatternPackage.PATTERN__ELEMENTS);
		}
		return elements;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getMultiplicities() {
		if (multiplicities == null) {
			multiplicities = new EObjectContainmentEList(Multiplicity.class, this, generalpatternPackage.PATTERN__MULTIPLICITIES);
		}
		return multiplicities;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getContainingRoles() {
		if (containingRoles == null) {
			containingRoles = new EObjectContainmentEList(Role.class, this, generalpatternPackage.PATTERN__CONTAINING_ROLES);
		}
		return containingRoles;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case generalpatternPackage.PATTERN__OPERATORS:
				return ((InternalEList)getOperators()).basicRemove(otherEnd, msgs);
			case generalpatternPackage.PATTERN__ELEMENTS:
				return ((InternalEList)getElements()).basicRemove(otherEnd, msgs);
			case generalpatternPackage.PATTERN__MULTIPLICITIES:
				return ((InternalEList)getMultiplicities()).basicRemove(otherEnd, msgs);
			case generalpatternPackage.PATTERN__CONTAINING_ROLES:
				return ((InternalEList)getContainingRoles()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case generalpatternPackage.PATTERN__OPERATORS:
				return getOperators();
			case generalpatternPackage.PATTERN__ELEMENTS:
				return getElements();
			case generalpatternPackage.PATTERN__MULTIPLICITIES:
				return getMultiplicities();
			case generalpatternPackage.PATTERN__CONTAINING_ROLES:
				return getContainingRoles();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case generalpatternPackage.PATTERN__OPERATORS:
				getOperators().clear();
				getOperators().addAll((Collection)newValue);
				return;
			case generalpatternPackage.PATTERN__ELEMENTS:
				getElements().clear();
				getElements().addAll((Collection)newValue);
				return;
			case generalpatternPackage.PATTERN__MULTIPLICITIES:
				getMultiplicities().clear();
				getMultiplicities().addAll((Collection)newValue);
				return;
			case generalpatternPackage.PATTERN__CONTAINING_ROLES:
				getContainingRoles().clear();
				getContainingRoles().addAll((Collection)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case generalpatternPackage.PATTERN__OPERATORS:
				getOperators().clear();
				return;
			case generalpatternPackage.PATTERN__ELEMENTS:
				getElements().clear();
				return;
			case generalpatternPackage.PATTERN__MULTIPLICITIES:
				getMultiplicities().clear();
				return;
			case generalpatternPackage.PATTERN__CONTAINING_ROLES:
				getContainingRoles().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case generalpatternPackage.PATTERN__OPERATORS:
				return operators != null && !operators.isEmpty();
			case generalpatternPackage.PATTERN__ELEMENTS:
				return elements != null && !elements.isEmpty();
			case generalpatternPackage.PATTERN__MULTIPLICITIES:
				return multiplicities != null && !multiplicities.isEmpty();
			case generalpatternPackage.PATTERN__CONTAINING_ROLES:
				return containingRoles != null && !containingRoles.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //PatternImpl
